package org.springleaf.utils;

import java.math.BigDecimal;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

/**
 * 数据转换类绑定
 * 
 * @author leaf
 * 
 */
public class MyWebBindingInitializer implements WebBindingInitializer {

	@Override
	public void initBinder(WebDataBinder binder, WebRequest webRequest) {
		// 注册日期转换
		binder.registerCustomEditor(Date.class, new MyCustomDateEditor(true));
		binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(
				BigDecimal.class, false));
	}

}
